﻿#ifndef JZTIMERMESSAGEBOX_H
#define JZTIMERMESSAGEBOX_H

#include <QMessageBox>
#include <QTimer>

class JZTimerMessageBox : public QMessageBox
{
    Q_OBJECT
public:
    // 构造函数，参数：消息文本、标题、按钮、超时时间(毫秒)、父窗口
    explicit JZTimerMessageBox(const QString &text, 
                              const QString &title = "",
                              StandardButtons buttons = NoButton,
                              int timeoutMs = 3000,
                              QWidget *parent = nullptr);
    
    // 静态方法，方便直接调用
    static void information(QWidget *parent, 
                           const QString &title, 
                           const QString &text, 
                           int timeoutMs = 3000);
    
    static void warning(QWidget *parent, 
                       const QString &title, 
                       const QString &text, 
                       int timeoutMs = 3000);
    
    static void critical(QWidget *parent, 
                        const QString &title, 
                        const QString &text, 
                        int timeoutMs = 3000);

private slots:
    void onTimeout();
    void updateCountdownText();

private:
    QTimer *m_timer;          // 用于自动关闭的定时器
    QTimer *m_countdownTimer; // 用于更新倒计时显示的定时器
    int m_remainingTime;      // 剩余时间(秒)
    QString m_originalText;   // 原始消息文本
};

#endif // JZTIMERMESSAGEBOX_H
